<template>
  <div id="aCoursesList" class="bg-fa of">
    <!-- 讲师列表 -->
    <section class="container">
      <section class="c-sort-box unBr">
        <div>
          <!-- 无数据提示 -->
          <section v-if="items.length===0" class="no-data-wrap">
            <span class="c-666 fsize14 ml10 vam">暂时没有相关数据</span>
          </section>
          <!-- 数据列表 -->
          <article v-if="items.length>0" class="i-teacher-list">
            <ul class="of">
              <li v-for="(item, index) in items" :key="index">
                  <el-card class="i-teach-wrap">
                    <!-- 讲师头像 -->
                    <div class="i-teach-pic">
                      <a :title="item.name" :href="'/teacher/'+item.id">
                        <img :src="item.avatar" :alt="item.name" width="142">
                      </a>
                    </div>
                    <!-- 讲师姓名 -->
                    <div class="mt10 hLh30 txtOf tac">
                      <a :title="item.name" :href="'/teacher/'+item.id" class="fsize18 c-666">{{ item.name }}</a>
                    </div>
                    <!-- 授课风格 -->
                    <div class="hLh30 txtOf tac">
                      <span class="fsize14 c-999">{{ item.style }}</span>
                    </div>
                    <!-- 讲师简介 -->
                    <div class="mt15 i-q-txt">
                      <p class="c-999 f-fM">{{ item.career }}</p>
                    </div>
                  </el-card>
              </li>
            </ul>
            <div class="clear"/>
          </article>
        </div>
      </section>
    </section>
  </div>
</template>

<script>
import teacherApi from '~/api/teacher'

export default {
  // 异步数据获取 在前端服务器端执行
  asyncData() {
    return teacherApi.queryAll().then(response => {
      return {
        items: response.data.items
      }
    })
  }
}
</script>
